<template>
    <div id="head" style="" v-show="!isMini">
        <div class="head-space"></div>
        <div class="nvagter">
            <img v-if="isBack" @click="back" class="arrow_index" src="./img/arrow-ji.png" />
            <span>{{title}}</span>
            <img v-if="isHome"  @click="home"  class="index" src="./img/shou.png" />
            <span v-if="signIn" @click="signOut" style="float:right" >退出登录</span>
            <!-- <img v-if="!isHome && this.title != '校园缴费'"  @click="login"  class="index" src="./img/shou.png" /> -->
        </div>
    </div>
</template>
<script>
import {loginUrl} from '@/config/config'
import cookie from '@/util/cookie'
export default {
  components: {
  },
  props:{
      title:{
          type:String
      },
    isBack:{
        type:Boolean,
        default:true
    },
    isHome:{
        type:Boolean,
        default:true
    },
    signIn:{
        type:Boolean,
        default: false
    },
    backBySelf: {
       type:Boolean,
        default:false
    }
  },
  computed:{
      isMini () {
          return this.$store.state.user.isMini
      }
    },
  data(){
    return {
   
    }
  },
  mounted () {
    

  },
  methods:{
    randomNum(min = 0, max = 100, len = 0) {
      return Number((min + (max - min) * Math.random()).toFixed(len));
    },
    randomStr(){
      let str = '';
      let list = '0123456789abcdefghijklmnopqrstuvwxyz';
      for (let i = 0; i < 8; i++) {
          let index = this.randomNum(0, 35);
          let word = list[index];
          if (isNaN(word) && this.randomNum() < 50) {
          word = word.toUpperCase();
          }
          str += word;
      }
      return str;
    },
    back(){
      if (this.backBySelf) {
        this.$emit('back')
        return
      }
      // if(this.title=="充值"){
      //     // this.$router.replace('/schoolAccount/index')
      //     this.$router.push('/myNew/oneCard')
      // }else if (this.title=="套餐中心" || this.title=="个人信息") {
      //      this.$router.push('/menu/index')
      // }else if (this.title=="校园账户") {
      //      this.$router.push('/settings/setUp')
      // }else if (this.title=="我的孩子" || this.title=="校园一卡通" || this.title=="学生证信息" || this.title=="审核列表" || this.title=="我的班级") {
      //      this.$router.push('/myNew/myNew')
      // }
      // else{
      //     this.$router.go(-1)
      // }
      this.$router.go(-1)
    },
    home(){
      this.$router.push('/menu/index')
    },
    login(){
      location.href = loginUrl
    },
    // 退出登录触发事件
    signOut () {
      this.$vux.confirm.show({
          title: '提示',
          content: '是否退出登录？',
          onConfirm : () => {
            this.$store.dispatch('setting/loginOut')
          },
          onCancel () {
          }
      })
    }
  }
}
</script>
<style scoped src="./css/head.css">

</style>
